import os # 导入os模块，模块的概念后面讲到
L1=[ x * x for x in range(1,11)]
print(L1)

L2 =[ x * x for x in range(1,11) if x %2 ==0] 
print(L2)

L3 = ['Hello', 'World', 18, 'Apple', None]
L4 = [s.lower() for s in  L3 if  isinstance(s, str)]
print(L4)

L5 = [m+n for m in "abc" for n in "ABC"]
print(L5)

# 列出当前目录下的所有文件和目录名
L6 = [d for d in os.listdir('.')]
print(L6)

# 同时使用两个甚至多个变量
d={'x':'1','y':'2','z':'3'}
for k,v in d.items():
	print(k,'=',v)
# 列表生成式也可以使用两个变量来生成list
L7 = [k+"="+v for k,v in d.items()]
print(L7)

# 把一个list中所有的字符串变成小写
L8 = ['Hello', 'World', 'IBM', 'Apple']
print([s.lower() for s in L8])